package com.tyjc.unique.view.ssq;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;

import com.tyjc.unique.view.ZouShiOnDraw;
import com.tyjc.lottery.R;


public class OnDrawBottom extends ZouShiOnDraw {
	
	private Paint bgPaint;
	private Paint linePaint;
	private Paint textPaint;
	
	private int color_bg;//灰
	private int color_line;
	private int color_text1;

	public OnDrawBottom(Context context) {
		super(context);
	}
	
	public OnDrawBottom(Context context, AttributeSet attrs) {
		super(context, attrs);
	}
	
	public OnDrawBottom(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}
	
	@Override
	protected void init(Context context) {
		super.init(context);
		color_bg = context.getResources().getColor(R.color.qianhui2);
		color_line = context.getResources().getColor(R.color.shu_line);
		color_text1 = context.getResources().getColor(R.color.zi_c);
		
		bgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
		bgPaint.setColor(color_bg);
		
		linePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
		linePaint.setColor(color_line);
		linePaint.setStrokeWidth(1);
		
		textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
		textPaint.setColor(color_text1);
		textPaint.setTextSize(16 * screen_density);
		
	}
	
	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		canvas.drawColor(Color.WHITE);
		
		for (int i = 1; i < (column+1); i++) {
			String text = "";
			if (i<10) {
				text = "0"+i;
			}else{
				text = ""+i;
			}
			int x0 = (int)(unitLength*(i-1));
			int x1 = (int)(unitLength*i);
			int y0 = 0;
			int y1 = (int)(unitLength);
			Rect rect = new Rect(x0, y0, x1, y1);
			
			//绘制背景颜色
			canvas.drawRect(rect, bgPaint);
			
			//绘制线条
			if (i != 1) {
				canvas.drawLine(x0, y0, x0, y1, linePaint);
			}
			
			//绘制文字
			drawText(canvas, textPaint, text, rect);
		}
	}
	
	@Override
	protected void setTotalWH() {
		totalWidth = unitLength * column;
		totalHeight = unitLength;
		setMeasuredDimension((int)totalWidth, (int)totalHeight);
		this.invalidate();
	}
	
}
